package com.dci.controller.construction;

import com.dci.model.construction.ConstructionInfo;
import com.dci.result.JsonData;
import com.dci.result.PageResult;
import com.dci.service.construction.ConstructionInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.controller.construction
 * @Description: 施工队管理
 * @author: 张星亮
 * @date: 2019/2/25
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */
@Controller
@RequestMapping("/construction")
@Api(value = "施工队管理")
public class ConstructionInfoController {

    @Resource
    private ConstructionInfoService constructionInfoService;


    /**
     * 施工队新增
     *
     * @param record
     * @return JsonData 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("施工队新增")
    public JsonData saveConstructionInfo(@RequestBody ConstructionInfo record) {
        try {
            return constructionInfoService.insert(record);
        } catch (Exception e) {
            e.printStackTrace();
            return JsonData.success("", 911);
        }
    }


    /**
     * 根据主键查询详细
     *
     * @param record
     * @return JsonData 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    @ResponseBody
    public JsonData selectByPrimaryKey(@RequestBody ConstructionInfo record) {
        try {
            return constructionInfoService.selectByPrimaryKey(record);
        } catch (Exception e) {
            e.printStackTrace();
            return JsonData.success("", 911);
        }
    }


    /**
     * 更新施工单位信息
     *
     * @param record
     * @return JsonData 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public JsonData updateByPrimaryKeySelective(@RequestBody ConstructionInfo record) {
        try {
            return constructionInfoService.updateByPrimaryKeySelective(record);
        } catch (Exception e) {
            e.printStackTrace();
            return JsonData.success("", 911);
        }
    }


    /**
     * 根据条件查询施工单位列表,分页
     *
     * @param record
     * @return PageResult 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @RequestMapping(value = "/getListPage", method = RequestMethod.POST)
    @ResponseBody
    public PageResult selectPageList(@RequestBody ConstructionInfo record) {
        try {
            return constructionInfoService.selectPageList(record);
        } catch (Exception e) {
            e.printStackTrace();
            return PageResult.fail(911);
        }
    }


    /**
     * 批量删除
     *
     * @param list
     * @return JsonData 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @RequestMapping("/delete")
    @ResponseBody
    public JsonData batchDelete(@RequestBody List<ConstructionInfo> list) {
        try {
            return constructionInfoService.batchDelete(list);
        } catch (Exception e) {
            e.printStackTrace();
            return JsonData.success("", 911);
        }
    }


}
